<table width="100%" cellpadding="8" align="center" border="1" bordercolor="#637AAE">
<tr>
	<td width="33%" align="center">
		<div id="chart1" style="width:325px;height:325px"></div>
	</td>	
	<td width="33%" align="center">
		<div id="chart2" style="width:325px;height:325px"></div>
	</td>	
	<td width="33%" align="center">
		<div id="chart3" style="width:325px;height:325px"></div>
	</td>		
</tr>
<tr>
	<td align="center">
		<div id="chart4" style="width:325px;height:325px"></div>
	</td>	
	<td align="center">
		<div id="chart5" style="width:325px;height:325px"></div>
	</td>	
	<td align="center">
		<div id="chart6" style="width:325px;height:325px"></div>
	</td>	
</tr>
</table>

<script type="text/javascript">		
	function showChart( i, title, data ){
		return new Highcharts.Chart({
			chart: {
				renderTo: 'chart'+i,
				plotBackgroundColor: null,
				plotBorderWidth: null,
				plotShadow: false
			},
			title: {
				text: title
			},
			tooltip: {
				formatter: function() {
					return '<b>'+ this.point.name +'</b>: '+ this.y + ' ('+ Math.round(this.point.percentage) +'%)';
				}
			},
			plotOptions: {
				pie: {
					allowPointSelect: true,
					cursor: 'pointer',
					dataLabels: {
						enabled: false
					},
					showInLegend: true
				}
			},
			series: data
		});	
	}


	$(function(){
		showChart(1,'Thống kê giới tính',[{
			type: 'pie',
			name: 'Nam',
			data: [
				['Nam',  <?php $this->e('male');?> ],
				['Nữ',   <?php $this->e('female');?>]
			]
		}]);
		
		showChart(2,'Thống kê tuổi nhân sự',[{
			type: 'pie',
			name: 'Age',
			data: [
				['20-30', <?php $this->e('age4');?>],
				['31-40', <?php $this->e('age3');?>],
				['41-50', <?php $this->e('age2');?>],
				['51-60', <?php $this->e('age1');?>]
			]
		}]);
		
		showChart(3,'Thống kê chuyên môn',[{
			type: 'pie',
			name: 'Skill',
			data: [
				<?php
					$b = array();
					$t=0;
					foreach($this->get('skill_stats') as $a ){
						$t+=$a['total'];
						$b[] = "['{$a['label']}', {$a['total']} ]"; 
					}
					
					$b[] = "['Không rõ',". ( $this->get('male') + $this->get('female')-$t)."]";
					
					_e( implode(',',$b) );
				?>
			]		
		}]);	
		
		/*
		showChart(4,'Thống kê tình trạng hôn nhân',[{
			type: 'pie',
			name: 'Age',
			data: [
				['20-30',   45.0],
				['35-40',    15.0],
				['40-45',    20.0],
				['45-60',    20.0]
			]
		}]);		*/

		showChart(4,'Tham gia Đảng',[{
			type: 'pie',
			name: 'Gov',
			data: [
				['Có', <?php $this->e('gov');?>],
				['Không', <?php $this->e('no_gov');?>]
			]
		}]);
	});
		
</script>